package com.timk.goserver.client.model;

import java.util.Date;

import com.google.gwt.user.client.rpc.IsSerializable;

/** */
public class Message implements IsSerializable {
	private int messageId;
	private String fromUser;
	private String toUser;
	private String subject;
	private String text;
	private Date date;
	
	/** */
	public Message() { /* */ }
	
	/**
	 * Creates a Message
	 * @param from
	 * @param to
	 * @param subject
	 * @param text
	 */
	public Message(String from, String to, String subject, String text) {
		this.fromUser = from;
		this.toUser = to;
		this.subject = subject;
		this.text = text;
		this.date = new Date();
	}
	
	/**
	 * Returns the message id
	 * @return the message id
	 */
	public int getMessageId() {
		return messageId;
	}
	
	/**
	 * Sets the message id
	 * @param messageId
	 */
	public void setMessageId(int messageId) {
		this.messageId = messageId;
	}
	
	/**
	 * Returns the user the message is from
	 * @return the user the message is from
	 */
	public String getFromUser() {
		return fromUser;
	}
	
	/**
	 * Sets the user the message is from
	 * @param fromUser
	 */
	public void setFromUser(String fromUser) {
		this.fromUser = fromUser;
	}
	
	/**
	 * Returns the subject
	 * @return the subject
	 */
	public String getSubject() {
		return subject;
	}

	/**
	 * Sets the subject
	 * @param subject
	 */
	public void setSubject(String subject) {
		this.subject = subject;
	}

	/**
	 * Returns the text of the message
	 * @return the text of the message
	 */
	public String getText() {
		return text;
	}
	
	/**
	 * Sets the text of the message
	 * @param text
	 */
	public void setText(String text) {
		this.text = text;
	}
	
	/**
	 * Returns the user the message is to
	 * @return the user the message is to
	 */
	public String getToUser() {
		return toUser;
	}
	
	/**
	 * Sets the user the message is to
	 * @param toUser
	 */
	public void setToUser(String toUser) {
		this.toUser = toUser;
	}

	/**
	 * Returns the date the message was created
	 * @return the date the message was created
	 */
	public Date getDate() {
		return date;
	}

	/**
	 * Sets the date the message was created
	 * @param date
	 */
	public void setDate(Date date) {
		this.date = date;
	}
	
	/**
	 * Replaces the hibernate date class, so that this
	 * object can be serialized
	 *
	 */
	public void sanitize() {
		date = new Date(date.getTime());
	}
}
